package com.gpstracking.DA;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.gpstracking.BE.Punto;

public class PuntoDA {

	public static boolean eliminar(int idArea) {
		try{
			Session hbsession = HUtil.getSession();
			Transaction tx = hbsession.beginTransaction();
			tx.begin();
			
			Query query = hbsession.createQuery("FROM Punto WHERE area.idArea = :idarea");
			query.setParameter("idarea", idArea);
			List<Punto> puntos = (List<Punto>)query.list();
			for( Punto it : puntos ){
				hbsession.delete(it); 
			}
			return true;
		}catch( Exception ex){
			ex.printStackTrace();
			return false;
		}
	}

}
